import {ref} from "@vue/reactivity";
import overMiddle1 from "@/assets/over-middle1.png";
import overMiddle2 from "@/assets/over-middle2.png";
import overMiddle3 from "@/assets/over-middle3.png";
import overMiddle4 from "@/assets/over-middle4.png";
import {Api} from "@/common/api";
import {requestMethod} from "@/common/request";

function urlGet(val) {
  return new URL(`../../assets/${val}.png`, import.meta.url);
}

export const middleItem = [
  {
    title: "运行保障（天）",
    key: "yxts",
    img: overMiddle1,
  },
  {
    title: "设备总数（个）",
    key: "sbzs",
    img: overMiddle2,
  },
  {
    title: "在线数量（个）",
    key: "zxsl",
    img: overMiddle3,
  },
  {
    title: "监测区域（个）",
    key: "jcqy",
    img: overMiddle4,
  },
];

export const leftItem = [
  {
    title: "周界监控",
    key: "zjjk",
    img: urlGet("zbjk"),
    color: "#B7FFFF",
  },
  {
    title: "通道监控",
    key: "tdjk",
    img: urlGet("tdjk"),
    color: "#E6B867",
  },
  {
    title: "门禁设备",
    key: "mjsb",
    img: urlGet("mjsb"),
    color: "#51A9C5",
  },
  {
    title: "停车位",
    key: "tcw",
    img: urlGet("tcw"),
    color: "#B7FFFF",
  },
  {
    title: "注册车辆",
    key: "zccl",
    img: urlGet("zccl"),
    color: "#E6B867",
  },
  {
    title: "当日车流量",
    key: "dqcl",
    img: urlGet("cll"),
    color: "#51A9C5",
  },
];

export const l2ColumnData = [
  {
    name: "plateNo",
    title: "车牌号码",
    flex: 2
  },
  {
    name: "vehicleOut",
    title: "状态",
  },
  {
    name: "crossTime",
    title: "时间",
    flex: 3
  },
];

export const r3ColumnData = [
  {
    name: "cameraName",
    title: "告警设备",
    flex:5
  },
  {
    name: "name",
    title: "告警类型",
    flex:4
  },
  {
    name: "sj",
    title: "告警时间",
    flex:5
  },
];
export const r3Data = [];
export const dateBtnItems = ["今日", "本周", "本月"];

export const l3ChartData = ref([
  {
    title: "晚归告警",
    value: 0,
    top: "10%",
    left: "80%",
    align: "right",
    key: "ycgj",
  },
  {
    title: "天台逗留",
    value: 0,
    top: "50%",
    left: "80%",
    align: "right",
    key: "ttgj",
  },
  {
    title: "异常人员",
    value: 0,
    top: "70%",
    left: "3%",
    key: "ycrygj",
  },
  {
    title: "上网行为",
    value: 0,
    top: "35%",
    left: "3%",
    key: "swgj",
  },
  {
    title: "失联告警",
    value: 0,
    top: "0%",
    left: "3%",
    key: "slgj",
  },
]);

export const R1Info = [
  {
    title: "当日车流量",
    key: "drcll"
  },
  {
    title: "当前车辆数",
    key: "dccls"
  },
];

export const R2Info = [
  {
    title: "当日人流量",
    key: "dqrll"
  },
  {
    title: "当前园区人数",
    key: "dqygs"
  },
];

export const handleChart = (res, name) => {
  let arr = [];
  for (const dataKey in res.data) {
    let item = res.data[dataKey];
    arr.push({
      time: dataKey,
      value: item,
      country: name[0]
    });
  }
  for (const dataKey in res.xw) {
    let item = res.xw[dataKey];
    arr.push({
      time: dataKey,
      value: item,
      country: name[1]
    });
  }
  return arr;
};

// 园区访客
export class OverviewL1 extends Api {
  constructor() {
    super("api/v1/yq-fk");
    this.method(requestMethod.GET);
  }
}

// 车位
export class OverviewL2 extends Api {
  constructor() {
    super("api/v1/yq-clxx");
    this.method(requestMethod.GET);
  }
}

// 统计事件处理比例
export class OverviewL3 extends Api {
  constructor() {
    super("api/v1/Jc-sjtj");
    this.method(requestMethod.GET);
  }
}

// 基础信息
export class OverviewRight extends Api {
  constructor() {
    super("api/v1/Jc-index");
    this.method(requestMethod.GET);
  }
}

// 基础数据
export class OverviewRightData extends Api {
  constructor() {
    super("api/v1/yq-fktj");
    this.method(requestMethod.GET);
  }
}

// 安防数据随机出2条
export class OverviewCamera extends Api {
  constructor() {
    super("api/v1/Xyhc-af");
    this.method(requestMethod.GET);
  }
}

// 车辆导出
export class OverviewExport extends Api {
  constructor() {
    super("api/v1/cldc");
    this.method(requestMethod.GET);
  }
}
